/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.model.dbconector;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 *
 * @author Lucas
 */
public class DataBaseConnector {

    private static Connection conn;
    private static DataBaseConnector dbConn;

    private DataBaseConnector() {
    }

    public static DataBaseConnector getInstance() {
        if (dbConn == null) {
            dbConn = new DataBaseConnector();
        }
        return dbConn;
    }

    public Connection getConnection() {
        if (conn == null) {
            try {
                Class.forName("org.postgresql.Driver");
                conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "postgres");
            } catch (ClassNotFoundException cnfe) {
                System.out.println("Classe não Encontrada");
            } catch (SQLException sqle) {
                System.out.println("Erro ao Conectar ao Banco: "+sqle.getMessage());
            }
        }
        return conn;
    }
}
